//
//  ST_LovedOfMeetYouCell.swift
//  btvideo
//
//  Created by mac on 2020/8/7.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//
/*
import UIKit

class ST_LovedOfMeetYouCell: UITableViewCell {

    static let height = 103.cgFloat
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        
        contentView.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10)
            make.left.equalToSuperview().offset(15)
            make.size.equalTo(CGSize.init(width: 58, height: 58))
        }
        
        contentView.addSubview(user_name_label)
        user_name_label.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(16)
            make.left.equalTo(icon_image_view.snp.right).offset(10)
            make.height.equalTo(25)
            if ScreenWidth < 400{
                make.width.lessThanOrEqualTo(82)
            }else{
                make.width.lessThanOrEqualTo(ScreenWidth/3.0)
            }
        }
        
        contentView.addSubview(faceSignImageView)
        faceSignImageView.snp.makeConstraints { (make) in
            make.centerY.equalTo(user_name_label)
            make.left.equalTo(user_name_label.snp.right).offset(4)
        }
        
        contentView.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.left.equalTo(user_name_label)
            make.top.equalTo(user_name_label.snp.bottom).offset(4)
            make.height.equalTo(17)
        }
        
        contentView.addSubview(online_sub_label)
        online_sub_label.snp.makeConstraints { (make) in
            make.left.centerY.equalTo(content_label)
        }
        
        contentView.addSubview(number_label)
        number_label.snp.makeConstraints { (make) in
            make.left.equalTo(user_name_label)
            make.top.equalTo(content_label.snp.bottom).offset(11)
            make.height.equalTo(20)
        }
        
        contentView.addSubview(look_btn)
        look_btn.snp.makeConstraints { (make) in
            make.width.equalTo(56)
            make.height.equalTo(30)
            make.top.equalToSuperview().offset(24)
            make.right.equalToSuperview().offset(-15)
        }
        
        contentView.addSubview(ignore_btn)
        ignore_btn.snp.makeConstraints { (make) in
            make.width.equalTo(56)
            make.height.equalTo(30)
            make.top.equalToSuperview().offset(24)
            make.right.equalToSuperview().offset(-81)
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
//    MARK:- properties
    fileprivate lazy var icon_image_view:UIImageView = {
       let control = UIImageView()
        control.contentMode = .scaleAspectFill
        control.cornerRadius = 58/2.0
        
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(push_user_center_handle))
        
        control.isUserInteractionEnabled = true
        
        control.addGestureRecognizer(tap)
        
        return control
    }()
    
    fileprivate lazy var user_name_label:UILabel = {
       let control = UILabel()
        control.textColor = UIColor.init(hexString: "#333333")
        control.font = UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.semibold)
        return control
    }()
    
    fileprivate lazy var content_label:UILabel = {
       let control = UILabel()
        control.textColor = UIColor.init(hexString: "#ACB4C0")
        control.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular)
        return control
    }()
    
    
    fileprivate lazy var online_sub_label:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.setImageForAllStates(UIImage.init(named: off_line_image_name)!)
        control.setImage(UIImage.init(named: on_line_image_name), for: UIControl.State.selected)
        control.setTitleForAllStates("  ")
        control.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: 5, bottom: 0, right: 0)
        control.setTitleColorForAllStates(UIColor.init(hex: 0xACB4C0)!)
        control.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.medium)
        control.isHidden = true
        return control
    }()
    
    
    fileprivate let off_line_image_name = "首页_icon_过往在线"
    fileprivate let on_line_image_name = "首页_icon_现在活跃"
    
    fileprivate lazy var number_label:UILabel = {
       let control = UILabel()
        return control
    }()
    
    fileprivate lazy var look_btn:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
       control.setTitleForAllStates("喜欢")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        control.backgroundColor = UIColor.init(hexString: "#FEC207")
        control.setTitleColorForAllStates(UIColor.white)
        control.cornerRadius = 15
        control.add_touch_up(insideTarget: self, action: #selector(loveSomebodyHandle))
        return control
    }()
    
    fileprivate lazy var ignore_btn:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
       control.setTitleForAllStates("忽略")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        control.backgroundColor = UIColor.init(hexString: "#DFE3E9")
        control.setTitleColorForAllStates(UIColor.white)
        control.cornerRadius = 15
        control.add_touch_up(insideTarget: self, action: #selector(ignoreHandle))
        return control
    }()
    
    fileprivate lazy var faceSignImageView:UIImageView = {
        let control = UIImageView()
         return control
    }()
//    fileprivate lazy var line:UIView = {
//       let control = UIView()
//        control.backgroundColor = Color.init(hexString: "#F2F4F7")
//        return control
//    }()
//
    weak var model:ST_MeetYouCellModel?{
        didSet{
            
            guard let m = model else { return  }
            
            icon_image_view.pin_setImage(from: m.avatar.compress_image().url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            
            user_name_label.text = m.nickname
            
            content_label.text = m.contentStr
            
            if m.contentStr.count < 1{
                
                online_sub_label.isSelected = m.online_state == "现在活跃"
                
                online_sub_label.setTitleForAllStates(m.online_state + "  ")
                
                online_sub_label.isHidden = false
                
            }else{
                online_sub_label.isHidden = true
            }
            
            number_label.attributedText = m.subContentAttrStr
            
            if CHECK_MEMBER_STATUS(expirationTime: m.vipExpire) == .subscribe{
                faceSignImageView.image = SC.YYMemberSignImage
            }else if m.faceAuditState == 3{
                faceSignImageView.image = SC.YYFaceSignImage
            }else{
                faceSignImageView.image = nil
            }
        }
    }
    
    var ignoreClosure:((String)->())?
}

extension ST_LovedOfMeetYouCell{
    
    @objc fileprivate func push_user_center_handle(){
        
        guard let m = model else { return }
        
        let vc = ST_PairsCenterViewController()
            
        vc.accid = m.accid

        let nav = PairsCenterInteractiveNavigationController.init(rootViewController: vc)
        
        nav.overCurrentContext = true
        
        GlobalPresent(toController: nav)
        
    }
    
    
    @objc fileprivate func loveSomebodyHandle() {
        
        
        guard let m = model else {
            return
        }
        
        FollowBehavior(info: ST_MatchUserInfo.init(accid: m.accid, avatar: m.avatar, nickname: m.nickname), followed: false) { (f, err) in
            
            if err != nil{
                self.ignoreClosure?(m.accid)
            }
        }
    }
    
    @objc func ignoreHandle(){
        
        self.ignore_btn.isUserInteractionEnabled = false
        
        JVrequest(PH.ignoreMeetForLoveApi,parameters: ["attention_id":model?.attentionId ?? ""] ,success: { (json) in
            
            if let id = self.model?.accid{
                self.ignoreClosure?(id)
            }
            
        self.ignore_btn.isUserInteractionEnabled = true
            
            
        }) { (code, err) in
            
            self.ignore_btn.isUserInteractionEnabled = true
            self.parentViewController?.toast(text: err)
        }
        
    }
}


//MARK: - Mask Cell
class LovedOfMeetYouVisualEffectCell: UITableViewCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        
        contentView.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10)
            make.left.equalToSuperview().offset(15)
            make.size.equalTo(CGSize.init(width: 58, height: 58))
        }
        
        contentView.addSubview(user_name_label)
        user_name_label.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(16)
            make.left.equalTo(icon_image_view.snp.right).offset(10)
            make.height.equalTo(25)
            if ScreenWidth < 400{
                make.width.lessThanOrEqualTo(82)
            }else{
                make.width.lessThanOrEqualTo(ScreenWidth/3.0)
            }
        }
        
        contentView.addSubview(faceSignImageView)
        faceSignImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(18)
            make.centerY.equalTo(user_name_label)
            make.left.equalTo(user_name_label.snp.right).offset(4)
        }
        
        contentView.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.left.equalTo(user_name_label)
            make.top.equalTo(user_name_label.snp.bottom).offset(4)
            make.height.equalTo(17)
        }
        
        contentView.addSubview(online_sub_label)
        online_sub_label.snp.makeConstraints { (make) in
            make.left.centerY.equalTo(content_label)
        }
        
        contentView.addSubview(number_label)
        number_label.snp.makeConstraints { (make) in
            make.left.equalTo(user_name_label)
            make.top.equalTo(content_label.snp.bottom).offset(11)
            make.height.equalTo(20)
        }
        
        contentView.addSubview(unlock_btn)
        unlock_btn.snp.makeConstraints { (make) in
            make.width.equalTo(86)
            make.height.equalTo(30)
            make.top.equalToSuperview().offset(24)
            make.right.equalToSuperview().offset(-15)
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
//    MARK:- properties
    fileprivate lazy var icon_image_view:UIImageView = {
       let control = UIImageView()
        control.contentMode = .scaleAspectFill
        control.cornerRadius = 58/2.0
        return control
    }()
    
    fileprivate lazy var user_name_label:UILabel = {
       let control = UILabel()
        control.textColor = UIColor.init(hexString: "#333333")
        control.font = UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.semibold)
        return control
    }()
    
    fileprivate lazy var content_label:UILabel = {
       let control = UILabel()
        control.textColor = UIColor.init(hexString: "#ACB4C0")
        control.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular)
        return control
    }()
    
    
    fileprivate lazy var online_sub_label:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.setImageForAllStates(UIImage.init(named: off_line_image_name)!)
        control.setImage(UIImage.init(named: on_line_image_name), for: UIControl.State.selected)
        control.setTitleForAllStates("  ")
        control.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: 5, bottom: 0, right: 0)
        control.setTitleColorForAllStates(UIColor.init(hex: 0xACB4C0)!)
        control.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.medium)
        control.isHidden = true
        return control
    }()
    
    
    fileprivate let off_line_image_name = "首页_icon_过往在线"
    fileprivate let on_line_image_name = "首页_icon_现在活跃"
    
    fileprivate lazy var number_label:UILabel = {
       let control = UILabel()
        return control
    }()
    
    fileprivate lazy var visual_effect_view:ST_CustomIntensityVisualEffectView = {
        let control = ST_CustomIntensityVisualEffectView.init(effect: UIBlurEffect(style: .light), intensity: 0.2)
        return control
    }()
    
    
    fileprivate lazy var unlock_btn:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
       control.setTitleForAllStates("解锁查看")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        control.backgroundColor = UIColor.init(hexString: "#FEC207")
        control.setTitleColorForAllStates(UIColor.white)
        control.cornerRadius = 15
        control.add_touch_up(insideTarget: self, action: #selector(unlockHandle))
        return control
    }()
    
    fileprivate lazy var faceSignImageView:UIImageView = {
        let control = UIImageView()
         return control
    }()
//    fileprivate lazy var line:UIView = {
//       let control = UIView()
//        control.backgroundColor = Color.init(hexString: "#F2F4F7")
//        return control
//    }()
//
    func create_visual_effect()  {
        if visual_effect_view.superview == nil{
            
            contentView.insertSubview(visual_effect_view, belowSubview: content_label)
            
            visual_effect_view.snp.makeConstraints { (make) in
                make.edges.equalToSuperview()
            }
        }
    }
    
    func remove_visual_effect()  {
        
        visual_effect_view.removeFromSuperview()
        
    }
    
    
    weak var model:ST_MeetYouCellModel?{
        didSet{
            
            guard let m = model else { return  }
            
            icon_image_view.pin_setImage(from: m.avatar.compress_image().url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            
            user_name_label.text = m.nickname
            
            content_label.text = m.contentStr
            
            
            if m.contentStr.count < 1{
                
                online_sub_label.isSelected = m.online_state == "现在活跃"
                
                online_sub_label.setTitleForAllStates(m.online_state + "  ")
                
                online_sub_label.isHidden = false
                
            }else{
                online_sub_label.isHidden = true
            }
            
            number_label.attributedText = m.subContentAttrStr
            
            if CHECK_MEMBER_STATUS(expirationTime: m.vipExpire) == .subscribe{
                faceSignImageView.image = SC.YYMemberSignImage
            }else if m.faceAuditState == 3{
                faceSignImageView.image = SC.YYFaceSignImage
            }else{
                faceSignImageView.image = nil
            }
        }
    }
}

extension LovedOfMeetYouVisualEffectCell{
    
    @objc func unlockHandle(){
        
        
        if FETCH_MEMBER_STATUS() != .subscribe{
                    
            MeetYouMemberToast(source: .遇见_喜欢了我)
            
            return
        }
        GlobalPresent(toController: PurcMemberViewController())
        
    }
}
*/
